package com.example.config;

import com.example.entity.UserEntity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Service;

/**
 * @Description: MySpringConfig
 * @ComponentScan:扫描包范围将对应 类注入到Spring 容器中
 * includeFilters ={@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = Service.class)},useDefaultFilters = false 只要 包上面 有 @Service 注解的就会注入到 Spring 容器中
 * excludeFilters ={@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = Service.class)},useDefaultFilters = true 只要 包上面 有 @Service 注解的就会排除掉
 * @Author: mingtian
 * @CreateDate: 2019/12/6 11:13
 * @Version: 1.0
 */
@Configuration
@ComponentScan(value = "com.example", excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Service.class)}, useDefaultFilters = false)
public class MySpringConfig {

    /**
     * bean 名称为 userEntity
     *
     * @return
     */
    @Bean
    public UserEntity userEntity() {
        return new UserEntity("db", "大白");
    }
}